//
//  TPDetailHospitalCell.m
//  Yimei
//
//  Created by xiaowu xiaowu on 2017/10/25.
//  Copyright © 2017年 xiaowu xiaowu. All rights reserved.
//

#import "TPDetailHospitalCell.h"

@implementation TPDetailHospitalCell
-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    if(self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]){
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        [self setup];
   }
    return self;
}
-(void)setup{
    
    self.backgroundColor = [UIColor whiteColor];
    
    [self.date_label mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.mas_equalTo(0.0);
        make.height.mas_equalTo(38.f);
        make.left.right.mas_equalTo(0.0);
        
    }];
    [self.date_label tp_addLineTopWithColor:TP_COLOR_240];
    
    self.image_view.contentMode = UIViewContentModeScaleAspectFill;
    [self.image_view mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.mas_equalTo(8.0);
        make.height.width.mas_equalTo(55.0);
        make.left.mas_equalTo(15.0);
        
    }];
    ViewRadius(self.image_view, 55.0/2);
    
    self.title_label.numberOfLines = 2;
    self.title_label.font = [UIFont boldSystemFontOfSize:17];
    [self.title_label mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(self.image_view);
        make.height.mas_lessThanOrEqualTo(40.0);
        make.height.mas_greaterThanOrEqualTo(30.0);
        make.right.mas_equalTo(-10.0);
        make.left.mas_equalTo(self.image_view.mas_right).offset(10.0);
    }];
    
    self.detail_label.font = fontSystemOfSize(14);
    self.detail_label.numberOfLines = 0;
    [self.detail_label mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(self.title_label.mas_bottom);
        make.right.mas_equalTo(self.title_label.mas_right);
        make.left.mas_equalTo(self.title_label.mas_left);
        make.bottom.mas_equalTo(self.date_label.mas_top).offset(-14.0);
    }];
    
    
}
-(void)setDetailModel:(TPProductDetailModel *)detailModel{
    _detailModel = detailModel;
    self.title_label.text = detailModel.clinic.clinic_name;
    
    
    self.detail_label.text = [NSString stringWithFormat:@"擅长：%@",detailModel.clinic.business];
    self.date_label.text = [NSString stringWithFormat:@"   地址：%@",[NSString stringWithFormat:@"%@%@%@%@",detailModel.clinic.province,detailModel.clinic.city,detailModel.clinic.area,detailModel.clinic.address]];
    [self.image_view ym_setImageWithURL:detailModel.clinic.logo placeholderImage:defaultLogo w:120];
    
}
@end

@implementation TPDetailHeader
-(instancetype)initWithFrame:(CGRect)frame{
    if(self = [super initWithFrame:frame]){
        [self setup];
    }
    return self;
}
-(void)setup{
    
    self.backgroundColor = [UIColor whiteColor];
    [self.titleButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(self);
        make.centerX.mas_equalTo(self);
    }];
    self.titleButton.titleLabel.font = fontSystemOfSize(15);
    self.titleButton.imageView.contentMode = UIViewContentModeScaleAspectFit;
    [self.titleButton setBackgroundImage:ImageNamed(@"Home_header_hot_bg") forState:UIControlStateSelected];
    [self.titleButton setBackgroundImage:[ImageNamed(@"TP_detail_title_bg") imageWithAlignmentRectInsets:UIEdgeInsetsMake(0, 30.0, 0, 10.0)] forState:UIControlStateNormal];
}
-(void)setText:(NSString *)text{
    _text = text;
    [self.titleButton setTitle:text forState:UIControlStateNormal];
    self.titleButton.selected = [text isEqualToString:@"可能喜欢"];
    if([text isEqualToString:@"可能喜欢"]){
        [self.titleButton mas_updateConstraints:^(MASConstraintMaker *make) {
            make.width.mas_equalTo(self.mas_width);
            make.height.mas_equalTo(51.0);
        }];
        self.titleButton.titleEdgeInsets = UIEdgeInsetsMake(0.0, 0, 0, 0);
    }else{
        [self.titleButton mas_updateConstraints:^(MASConstraintMaker *make) {
            make.width.mas_equalTo(100.0);
            make.height.mas_equalTo(34.0);
        }];
        self.titleButton.titleEdgeInsets = UIEdgeInsetsMake(5.0, 0, 0, 0);
    }
    
    [self.titleButton layoutIfNeeded];
    [self layoutIfNeeded];
    
}
@end

